/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controladores;

import Hndlr.HndlrAdmin;
import Interfaces.ICtrlInicioSesion;

/**
 *
 * @author Sebas
 */
public class CtrlInicioSesion implements ICtrlInicioSesion{
    
    
    public CtrlInicioSesion() {
    }
    

    @Override
    public void logout() {
        
        HndlrAdmin hAdmin = HndlrAdmin.getInstance();
        
        hAdmin.setMailAdmin("");
        
    }
    
    @Override
    public boolean login(String email, String password) {


        HndlrAdmin hAdmin = HndlrAdmin.getInstance();

        boolean existeAdm, passCorrecta = false;

        //        //Existe el Administrador.
        existeAdm = hAdmin.containsKey(email);
        
        if (existeAdm) {
            if (hAdmin.get(email).getPass().equals(password)) {
                passCorrecta = true;
                hAdmin.setMailAdmin(email);
            }
        }

        if (existeAdm && passCorrecta) {
            return true;
        } else {
            return false;
        }

    }
}
